ShareCompat

Extra helper functionality for sharing data between activities. ShareCompat provides functionality to extend the ACTION_SEND/ ACTION_SEND_MULTIPLE protocol and support retrieving more info about the activity that invoked a social sharing action. IntentBuilder provides helper functions for constructing a sharing intent that always includes data about the calling activity and app. This lets the called activity provide attribution for the app that shared content. Constructing an intent this way can be done in a method-chaining style. To obtain an IntentBuilder with info about your calling activity, use the static method from. IntentReader provides helper functions for parsing the defined extras within an ACTION_SEND or ACTION_SEND_MULTIPLE intent used to launch an activity. You can also obtain a Drawable for the caller's application icon and the application's localized label (the app's human-readable name). Social apps that enable sharing content are encouraged to use this information to call out the app that the content was shared from.

Types

Link copied to clipboard
open class IntentBuilder
IntentBuilder is a helper for constructing ACTION_SEND and ACTION_SEND_MULTIPLE sharing intents and starting activities to share content.
Link copied to clipboard
open class IntentReader
IntentReader is a helper for reading the data contained within a sharing (ACTION_SEND) Intent.

Properties

Link copied to clipboard
val EXTRA_CALLING_ACTIVITY: String = "androidx.core.app.EXTRA_CALLING_ACTIVITY"
Intent extra that stores the ComponentName of the calling activity for an ACTION_SEND intent.
Link copied to clipboard
val EXTRA_CALLING_ACTIVITY_INTEROP: String = "android.support.v4.app.EXTRA_CALLING_ACTIVITY"
Intent extra that stores the ComponentName of the calling activity for an ACTION_SEND intent.
Link copied to clipboard
val EXTRA_CALLING_PACKAGE: String = "androidx.core.app.EXTRA_CALLING_PACKAGE"
Intent extra that stores the name of the calling package for an ACTION_SEND intent.
Link copied to clipboard
val EXTRA_CALLING_PACKAGE_INTEROP: String = "android.support.v4.app.EXTRA_CALLING_PACKAGE"
Intent extra that stores the name of the calling package for an ACTION_SEND intent.

Functions

Link copied to clipboard
open fun configureMenuItem(@NonNull item: @NonNull MenuItem, @NonNull shareIntent: @NonNull ShareCompat.IntentBuilder)
Configure a MenuItem to act as a sharing action.
open fun configureMenuItem(@NonNull menu: @NonNull Menu, @IdRes menuItemId: Int, @NonNull shareIntent: @NonNull ShareCompat.IntentBuilder)
Configure a menu item to act as a sharing action.
Link copied to clipboard
@Nullable
open fun getCallingActivity(@NonNull calledActivity: @NonNull Activity): @Nullable ComponentName
Retrieve the ComponentName of the activity that launched calledActivity from a share intent.
Link copied to clipboard
@Nullable
open fun getCallingPackage(@NonNull calledActivity: @NonNull Activity): @Nullable String
Retrieve the name of the package that launched calledActivity from a share intent.